// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.ast.SQLReplaceable;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

#include "SQLShowTableGroupsStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../SQLName.h"

SQLName_ptr SQLShowTableGroupsStatement::getDatabase()
{
  return database;
}

void SQLShowTableGroupsStatement::setDatabase(SQLName_ptr database)
{
  if (database != nullptr)
  {
    database->setParent(SharedObject(SQLShowTableGroupsStatement));
  }

  this->database = database;
}

// @Override
void SQLShowTableGroupsStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLShowTableGroupsStatement)))
  {
    acceptChild(visitor, database);
  }
}

// @Override
BOOL_ptr SQLShowTableGroupsStatement::replace(SQLExpr_ptr expr, SQLExpr_ptr target)
{
  if (database == expr)
  {
    setDatabase(std::dynamic_pointer_cast<SQLName>(target));
    return BOOL::TRUE;
  }

  return BOOL::FALSE;
}
